//
//  HACDispatcherViewControllerManage.m
//  HACDispatcher
//
//  Created by J.Cheng on 2019/5/14.
//  Copyright © 2019 Happy. All rights reserved.
//

#import "HACDispatcherViewControllerManage.h"
#import "HACDemoOneCell.h"
#import "HACDemoTwoCell.h"
#import "HACLayoutCell.h"

@implementation HACDispatcherViewControllerManage
- (void)loadDataFromServerSuccess:(void(^)(NSArray<NSMutableArray<id<HACTableViewCellModelProtocol>> *>* resultData))success {
    // 模拟加载
    __weak HACDispatcherViewControllerManage *weakSelf = self;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        __strong HACDispatcherViewControllerManage *strongSelf = weakSelf;
        if (strongSelf) {
            NSInteger index = 20;
            NSMutableArray<id <HACTableViewCellModelProtocol>> *mutableOne = [NSMutableArray array];
            NSMutableArray<id <HACTableViewCellModelProtocol>> *mutableTwo = [NSMutableArray array];
            NSMutableArray<id <HACTableViewCellModelProtocol>> *mutableThree = [NSMutableArray array];
            do {
                // 第一组数据
                {
                    HACDemoOneCellModel *one = [HACDemoOneCellModel new];
                    one.age = arc4random() % 20 + 10;
                    if (one.age % 2) {
                        one.name = [@"abc" stringByAppendingString:@(one.age).stringValue];
                    } else {
                        one.name = [@"诸葛" stringByAppendingString:@(one.age).stringValue];
                    }
                    [mutableOne addObject:one];
                }
                // 第二组数据
                {
                    HACDemoTwoCellModel *two = [HACDemoTwoCellModel new];
                    two.grade = arc4random() % 6;
                    two.school = [@"小学" stringByAppendingString:@(two.grade).stringValue];
                    [mutableTwo addObject:two];
                }
                
                {
                    HACLayoutCellModel *three = [HACLayoutCellModel new];
                    NSString *stuName = @"5月14日，明晟公司(MSCI)如期公布了A股纳入MSCI比例首批从5%提高到10%的扩容名单，有26只A股(含18只创业板股票)被纳入MSCI中国指数。至此，纳入MSCI的A股总共有大盘A股264只；另外，MSCI中国A股在岸指数新增109只成份股。这一系列调整将于5月28日收盘后正式生效。国金证券首席策略分析师李立峰在5月14日对《证券日报》记者表示，这是今年A股纳入MSCI比例提升方案三步走的第一步，A股纳入因子比例从5%提升至10%后，A股在MSCI中国指数、MSCI新兴市场指数中的权重将分别为5.25%、1.76%。根据测算，第一步带来的增量资金约1524亿元；其中，被动增量约305亿元，主动增量资金约1219亿元；被动资金一般在正式生效前后进行配置，主动资金则相对灵活。";
                    three.studentName = [stuName substringToIndex:(arc4random() % stuName.length)];
                    [mutableThree addObject:three];
                }
                
                index--;
            } while (index);
            
            if (success) {
                self.dataResponse = @[mutableOne, mutableTwo, mutableThree];
                success(@[mutableOne, mutableTwo, mutableThree]);
            }
        }
    });
}
@end
